﻿using LoggerTest.CustomLogger;
using LoggerTest.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.IO;

namespace LoggerTest
{
    public class Program
    {
        public static async Task Main(string[] args)
        {
            HostApplicationBuilder applicationBuilder = Host.CreateApplicationBuilder(args);
            applicationBuilder.Logging.ClearProviders();
            //applicationBuilder.Logging.AddConsole();
            //applicationBuilder.Logging.AddDebug();
            applicationBuilder.Services.AddSingleton<ILoggerProvider, CustomLoggerProvider>();
            applicationBuilder.Services.AddHostedService<HelloWorldService>();
            IConfigurationSection config = applicationBuilder.Configuration.GetSection("Logging:Custom");
            applicationBuilder.Services.Configure<CustomLoggerOptions>(config);
            //applicationBuilder.Services.Configure<CustomLoggerOptions>(config =>
            //{
            //    config.Color = ConsoleColor.DarkRed;
            //});
            applicationBuilder.Services.Configure<LoggerFilterOptions>(config =>
            {
            });
            IHost host = applicationBuilder.Build();
            await host.RunAsync();
        }
    }
}
